<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/pages/home.xhtml">
	<ui:define name="title">
		<h:outputText value="#{text.titOrgao}" />
	</ui:define>
	<ui:define name="js">
		<h:outputScript name="jquery.meioMask.1.1.3.js" library="js"></h:outputScript>
	</ui:define>
	<ui:define name="content">
		<p:fieldset id="fieldSetOrgao" binding="#{orgaoController.fieldSetOrgao}">
			<h:inputHidden id="orgaoId"
				value="#{orgaoController.selectedOrgao.idOrgao}" />
			<h:panelGrid id="pnlFields" columns="3">

				<h:outputLabel for="cod" value="#{text.lblOrgaoCodigo}" />
				<p:inputText id="cod" required="true" size="10" maxlength="5"
					requiredMessage="#{message.requiredOrgaoCodigo}"
					value="#{orgaoController.selectedOrgao.codOrgao}" />
				<p:message for="cod" />

				<h:outputLabel for="desc" value="#{text.lblOrgaoDesc}" />
				<p:inputText id="desc" required="true" size="50" maxlength="40"
					requiredMessage="#{message.requiredOrgaoDesc}"
					value="#{orgaoController.selectedOrgao.descOrgao}" />
				<p:message for="desc" />

				<h:outputLabel for="taxa" value="#{text.lblOrgaoTaxa}" />
				<p:inputMask id="taxa" size="25" maxlength="15"
					value="#{orgaoController.selectedOrgao.valTaxa}" required="true"
					requiredMessage="#{message.requiredOrgaoTaxa}"
					styleClass="inputTaxa" />
				<p:message for="taxa" />

				<h:outputScript>
					$(".inputTaxa").setMask({
	   	    			mask:"99.999999999999", 
		    			autoTab: false,
						maxLength: 14,
						type: 'reverse'
	    			});
				</h:outputScript>
			</h:panelGrid>


			<p:separator />

			<p:commandButton id="btnNew" value="#{text.btnNew}"
				icon="ui-icon-document" actionListener="#{orgaoController.newOrgao}"
				immediate="true" update=":frmContent:fieldSetOrgao"
				onclick="grdOrgao.unselectAllRows();clearRadioDataTable();" />
			<p:commandButton id="btnSave" value="#{text.btnSave}"
				icon="ui-icon-disk"
				update=":frmContent:fieldSetOrgao, :frmContent:grdOrgao"
				actionListener="#{orgaoController.saveOrgao}"
				process=":frmContent:fieldSetOrgao" />
			<p:commandButton id="btnDelete" value="#{text.btnDelete}"
				icon="ui-icon-trash" onclick="dialogDelete.show()"
				binding="#{orgaoController.btnDelete}" disabled="true" global="false"/>
			<p:confirmDialog id="dlgConfirmDelete" widgetVar="dialogDelete"
				closable="true" severity="info" appendToBody="true"
				header="#{text.dlgConfirm}" message="#{message.confirmDelete}"
				width="400">
				<p:commandButton id="btnConfirmDelete"
					actionListener="#{orgaoController.deleteOrgao}"
					value="#{text.btnConfirm}" icon="ui-icon-check"
					oncomplete="dialogDelete.hide()"
					update=":frmContent:fieldSetOrgao, :frmContent:grdOrgao" />
				<p:commandButton id="btnDeclineDelete" onclick="dialogDelete.hide()"
					value="#{text.btnCancel}" icon="ui-icon-cancel" global="false"/>
			</p:confirmDialog>

		</p:fieldset>

		<p:spacer height="25" />

		<p:dataTable id="grdOrgao" var="orgao"
			value="#{orgaoController.orgaoDataModel}" widgetVar="grdOrgao"
			emptyMessage="#{text.grdEmpty}"
			selection="#{orgaoController.selectedOrgao}" paginator="true"
			rows="10" rowsPerPageTemplate="10,25,50"
			paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
			sortBy="#{orgao.descOrgao}">

			<p:ajax event="rowSelect" update=":frmContent:fieldSetOrgao"
				listener="#{orgaoController.selectOrgao}" />

			<p:column selectionMode="single" style="width:18px" />
			<p:column id="colOrgaoCod" headerText="#{text.lblOrgaoCodigo}"
				sortBy="#{orgao.codOrgao}">
				<h:outputText value="#{orgao.codOrgao}" styleClass="cell-align-right"/>
			</p:column>
			<p:column id="colOrgaoDesc" headerText="#{text.lblOrgaoDesc}"
				sortBy="#{orgao.descOrgao}">
				<h:outputText value="#{orgao.descOrgao}" />
			</p:column>
			<p:column id="colOrgaoTaxa" headerText="#{text.lblOrgaoTaxa}"
				sortBy="#{orgao.valTaxa}" style="width:100px;">
				<h:outputText value="#{orgao.valTaxa}" styleClass="cell-align-right"/>
			</p:column>
		</p:dataTable>


	</ui:define>
</ui:composition>

</html>